home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WINGs / WUtil.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-02  |  19.0 KB  |  712 lines

  1. #ifndef _WUTIL_H_
  2. #define _WUTIL_H_
  3.  
  4. #include <X11/Xlib.h>
  5. #include <limits.h>
  6. #include <sys/types.h>
  7.  
  8. /* SunOS 4.x Blargh.... */
  9. #ifndef NULL
  10. #define NULL ((void*)0)
  11. #endif
  12.  
  13. /*
  14.  * Warning: proplist.h #defines BOOL which will clash with the
  15.  * typedef BOOL in Xmd.h
  16.  * proplist.h should use Bool (which is a #define in Xlib.h) instead.
  17.  *
  18.  */
  19. #include <proplist.h>
  20.  
  21.  
  22. #ifndef WMAX
  23. # define WMAX(a,b)    ((a)>(b) ? (a) : (b))
  24. #endif
  25. #ifndef WMIN
  26. # define WMIN(a,b)    ((a)<(b) ? (a) : (b))
  27. #endif
  28.  
  29.  
  30. #if (!defined (__GNUC__) || __GNUC__ < 2 || \
  31.      __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4))
  32. #define __ASSERT_FUNCTION       ((char *) 0)
  33. #else
  34. #define __ASSERT_FUNCTION       __PRETTY_FUNCTION__
  35. #endif
  36.  
  37.  
  38. #ifdef NDEBUG
  39.  
  40. #define wassertr(expr)        {}
  41. #define wassertrv(expr, val)    {}
  42.  
  43. #else /* !NDEBUG */
  44.  
  45. #ifdef DEBUG
  46.  
  47. #include <assert.h>
  48.  
  49. #define wassertr(expr)     assert(expr)
  50.  
  51. #define wassertrv(expr, val)    assert(expr)
  52.  
  53. #else /* !DEBUG */
  54.  
  55. #define wassertr(expr) \
  56.     if (!(expr)) { \
  57.         wwarning("%s line %i (%s): assertion %s failed",\
  58.             __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
  59.         return;\
  60.     }
  61.  
  62. #define wassertrv(expr, val) \
  63.     if (!(expr)) { \
  64.         wwarning("%s line %i (%s): assertion %s failed",\
  65.             __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
  66.         return (val);\
  67.     }
  68. #endif /* !DEBUG */
  69.  
  70. #endif /* !NDEBUG */
  71.  
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif /* __cplusplus */
  76.  
  77.  
  78. typedef enum {
  79.     WMPostWhenIdle = 1,
  80.     WMPostASAP = 2,
  81.     WMPostNow = 3
  82. } WMPostingStyle;
  83.  
  84.  
  85. typedef enum {
  86.     WNCNone = 0,
  87.     WNCOnName = 1,
  88.     WNCOnSender = 2
  89. } WMNotificationCoalescing;
  90.  
  91.  
  92. /* The possible states for connections */
  93. typedef enum {
  94.     WCNotConnected=0,
  95.     WCListening,
  96.     WCInProgress,
  97.     WCFailed,
  98.     WCConnected,
  99.     WCDied,
  100.     WCClosed
  101. } WMConnectionState;
  102.  
  103.  
  104.  
  105. enum {
  106.     WBNotFound = INT_MIN /* element was not found in bag */
  107. };
  108.  
  109.  
  110. typedef struct W_Bag WMBag;
  111. typedef struct W_Data WMData;
  112. typedef struct W_HashTable WMHashTable;
  113. typedef struct W_UserDefaults WMUserDefaults;
  114. typedef struct W_Notification WMNotification;
  115. typedef struct W_NotificationQueue WMNotificationQueue;
  116. typedef struct W_Host WMHost;
  117. typedef struct W_Connection WMConnection;
  118.  
  119.  
  120.  
  121. typedef struct {
  122.     int position;
  123.     int count;
  124. } WMRange;
  125.  
  126.  
  127.  
  128. /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
  129. typedef struct {
  130.     void *table;
  131.     void *nextItem;
  132.     int index;
  133. } WMHashEnumerator;
  134.  
  135.  
  136. typedef struct {
  137.     /* NULL is pointer hash */
  138.     unsigned     (*hash)(const void *);
  139.     /* NULL is pointer compare */
  140.     Bool    (*keyIsEqual)(const void *, const void *);
  141.     /* NULL does nothing */
  142.     void*    (*retainKey)(const void *);
  143.     /* NULL does nothing */
  144.     void    (*releaseKey)(const void *);    
  145. } WMHashTableCallbacks;
  146.  
  147.     
  148. typedef void *WMBagIterator;
  149.  
  150. typedef struct W_BagFunctions {
  151.     int (*getItemCount)(WMBag *self);
  152.     int (*appendBag)(WMBag *self, WMBag *bag);
  153.     int (*putInBag)(WMBag *self, void *item);
  154.     int (*insertInBag)(WMBag *self, int index, void *item);
  155.     int (*removeFromBag)(WMBag *bag, void *item);
  156.     int (*eraseFromBag)(WMBag *bag, int index);
  157.     int (*deleteFromBag)(WMBag *bag, int index);
  158.     void *(*getFromBag)(WMBag *bag, int index);
  159.     int (*firstInBag)(WMBag *bag, void *item);
  160.     int (*countInBag)(WMBag *bag, void *item);
  161.     void *(*replaceInBag)(WMBag *bag, int index, void *item);
  162.     int (*sortBag)(WMBag *bag, int (*comparer)(const void*, const void*));
  163.     void (*emptyBag)(WMBag *bag);
  164.     void (*freeBag)(WMBag *bag);
  165.     void (*mapBag)(WMBag *bag, void (*function)(void*, void*), void *data);
  166.     int (*findInBag)(WMBag *bag, int (*match)(void*, void*), void *cdata);
  167.     void *(*first)(WMBag *bag, WMBagIterator *ptr);
  168.     void *(*last)(WMBag *bag, WMBagIterator *ptr);
  169.     void *(*next)(WMBag *bag, WMBagIterator *ptr);
  170.     void *(*previous)(WMBag *bag, WMBagIterator *ptr);
  171.     void *(*iteratorAtIndex)(WMBag *bag, int index, WMBagIterator *ptr);
  172.     int (*indexForIterator)(WMBag *bag, WMBagIterator ptr);
  173. } W_BagFunctions;
  174.  
  175.     
  176. struct W_Bag {
  177.     void *data;
  178.     
  179.     void (*destructor)(void *item);
  180.     
  181.     W_BagFunctions func;
  182. };
  183.  
  184.  
  185.  
  186. #if 0
  187. typedef struct {
  188.     char character;               /* the escape character */
  189.     char *value;               /* value to place */
  190. } WMSEscapes;
  191. #endif
  192.  
  193.  
  194. /* The connection callbacks */
  195. typedef struct ConnectionDelegate {
  196.     void *data;
  197.  
  198.     void (*didCatchException)(struct ConnectionDelegate *self,
  199.                               WMConnection *cPtr);
  200.  
  201.     void (*didDie)(struct ConnectionDelegate *self, WMConnection *cPtr);
  202.  
  203.     void (*didInitialize)(struct ConnectionDelegate *self, WMConnection *cPtr);
  204.  
  205.     void (*didReceiveInput)(struct ConnectionDelegate *self, WMConnection *cPtr);
  206.  
  207.     void (*didTimeout)(struct ConnectionDelegate *self, WMConnection *cPtr);
  208.  
  209. } ConnectionDelegate;
  210.  
  211.  
  212. typedef void WMNotificationObserverAction(void *observerData, 
  213.                       WMNotification *notification);
  214.  
  215.  
  216.  
  217. /*......................................................................*/
  218.  
  219. typedef void (waborthandler)(int);
  220.  
  221. waborthandler *wsetabort(waborthandler*);
  222.  
  223.  
  224. /* don't free the returned string */
  225. char *wstrerror(int errnum);
  226.  
  227. void wfatal(const char *msg, ...);
  228. void wwarning(const char *msg, ...);
  229. void wsyserror(const char *msg, ...);
  230. void wsyserrorwithcode(int error, const char *msg, ...);
  231.  
  232. char *wfindfile(char *paths, char *file);
  233.  
  234. char *wfindfileinlist(char **path_list, char *file);
  235.  
  236. char *wfindfileinarray(proplist_t array, char *file);
  237.     
  238. char *wexpandpath(char *path);
  239.  
  240. /* don't free the returned string */
  241. char *wgethomedir();
  242.  
  243. void *wmalloc(size_t size);
  244. void *wrealloc(void *ptr, size_t newsize);
  245. void wfree(void *ptr);
  246.  
  247.  
  248. void wrelease(void *ptr);
  249. void *wretain(void *ptr);
  250.  
  251. char *wstrdup(char *str);
  252.  
  253. char *wstrappend(char *dst, char *src);
  254.  
  255. char *wusergnusteppath();
  256.  
  257. char *wdefaultspathfordomain(char *domain);
  258.  
  259. void wusleep(unsigned int microsec);
  260.  
  261. #if 0
  262. int wsprintesc(char *buffer, int length, char *format, WMSEscapes **escapes,
  263.            int count);
  264. #endif
  265.  
  266. /*......................................................................*/
  267.  
  268. /* This function is used _only_ if you create a NON-GUI program.
  269.  * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
  270.  * This function will handle all input/timer/idle events, then return.
  271.  */
  272.  
  273. void WHandleEvents();
  274.  
  275. /*......................................................................*/
  276.  
  277.  
  278. WMHashTable *WMCreateHashTable(WMHashTableCallbacks callbacks);
  279.  
  280. void WMFreeHashTable(WMHashTable *table);
  281.  
  282. void WMResetHashTable(WMHashTable *table);
  283.  
  284. void *WMHashGet(WMHashTable *table, const void *key);
  285.  
  286. /* put data in table, replacing already existing data and returning
  287.  * the old value */
  288. void *WMHashInsert(WMHashTable *table, void *key, void *data);
  289.  
  290. void WMHashRemove(WMHashTable *table, const void *key);
  291.  
  292. /* warning: do not manipulate the table while using these functions */
  293. WMHashEnumerator WMEnumerateHashTable(WMHashTable *table);
  294.  
  295. void *WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
  296.  
  297. unsigned WMCountHashTable(WMHashTable *table);
  298.  
  299.  
  300.  
  301.  
  302. /* some predefined callback sets */
  303.  
  304. extern const WMHashTableCallbacks WMIntHashCallbacks;
  305. /* sizeof(keys) are <= sizeof(void*) */
  306.  
  307. extern const WMHashTableCallbacks WMStringHashCallbacks;
  308. /* keys are strings. Strings will be copied with wstrdup() 
  309.  * and freed with free() */
  310.  
  311. extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
  312. /* keys are strings, bug they are not copied */
  313.  
  314.  
  315. /*......................................................................*/
  316.  
  317.  
  318. /*
  319.  * Array bags use an array to store the elements.
  320.  * Item indexes may be any integer number.
  321.  * 
  322.  * Pros:
  323.  * Fast [O(1)] access to elements
  324.  * Fast [O(1)] push/pop
  325.  * 
  326.  * Cons:
  327.  * A little slower [O(n)] for insertion/deletion of elements that 
  328.  *     arent in the end
  329.  * Element indexes with large difference will cause large holes
  330.  */
  331. #if 0
  332. WMBag* WMCreateArrayBag(int initialSize);
  333. WMBag* WMCreateArrayBagWithDestructor(int initialSize, 
  334.                       void (*destructor)(void*));
  335. #endif
  336. /*
  337.  * Tree bags use a red-black tree for storage.
  338.  * Item indexes may be any integer number.
  339.  * 
  340.  * Pros:
  341.  * O(lg n) insertion/deletion/search
  342.  * Good for large numbers of elements with sparse indexes
  343.  * 
  344.  * Cons:
  345.  * O(lg n) insertion/deletion/search
  346.  * Slow for storing small numbers of elements
  347.  */
  348. WMBag *WMCreateTreeBag(void);
  349. WMBag *WMCreateTreeBagWithDestructor(void (*destructor)(void*));
  350.  
  351.     
  352. #define WMCreateArrayBag(a) WMCreateTreeBag()
  353. #define WMCreateArrayBagWithDestructor(a,d) WMCreateTreeBagWithDestructor(d)
  354.     
  355. #define WMCreateBag(size) WMCreateTreeBag()
  356.  
  357. #define WMGetBagItemCount(bag) bag->func.getItemCount(bag)
  358.  
  359. #define WMAppendBag(bag, other) bag->func.appendBag(bag, other)
  360.  
  361. #define WMPutInBag(bag, item) bag->func.putInBag(bag, item)
  362.  
  363. /* insert will increment the index of elements after it by 1 */
  364. #define WMInsertInBag(bag, index, item) bag->func.insertInBag(bag, index, item)
  365.  
  366. /* this is slow */
  367. /* erase will remove the element from the bag,
  368.  * but will keep the index of the other elements unchanged */
  369. #define WMEraseFromBag(bag, index) bag->func.eraseFromBag(bag, index)
  370.  
  371. /* delete and remove will remove the elements and cause the elements
  372.  * after them to decrement their indexes by 1 */
  373. #define WMRemoveFromBag(bag, item) bag->func.removeFromBag(bag, item)
  374.  
  375. #define WMDeleteFromBag(bag, index) bag->func.deleteFromBag(bag, index)
  376.  
  377. #define WMGetFromBag(bag, index) bag->func.getFromBag(bag, index)
  378.  
  379. #define WMCountInBag(bag, item) bag->func.countInBag(bag, item)
  380.  
  381. #define WMReplaceInBag(bag, index, item) bag->func.replaceInBag(bag, index, item)
  382. #define WMSetInBag(bag, index, item) bag->func.replaceInBag(bag, index, item)
  383.  
  384. /* comparer must return:
  385.  * < 0 if a < b
  386.  * > 0 if a > b
  387.  * = 0 if a = b
  388.  */
  389. #define WMSortBag(bag, comparer) bag->func.sortBag(bag, comparer)
  390.  
  391. #define WMEmptyBag(bag) bag->func.emptyBag(bag)
  392.     
  393. #define WMFreeBag(bag) bag->func.freeBag(bag)
  394.  
  395. #define WMMapBag(bag, function, cdata) bag->func.mapBag(bag, function, cdata)
  396.  
  397. #define WMGetFirstInBag(bag, item) bag->func.firstInBag(bag, item)
  398.     
  399. #define WMCountInBag(bag, item) bag->func.countInBag(bag, item)
  400.  
  401. #define WMFindInBag(bag, match, cdata) bag->func.findInBag(bag, match, cdata)
  402.     
  403. #define WMBagFirst(bag, ptr) bag->func.first(bag, ptr)
  404.  
  405. #define WMBagLast(bag, ptr) bag->func.last(bag, ptr)
  406.     
  407. #define WMBagNext(bag, ptr) bag->func.next(bag, ptr)
  408.     
  409. #define WMBagPrevious(bag, ptr) bag->func.previous(bag, ptr)
  410.  
  411. #define WMBagIteratorAtIndex(bag, index, ptr) bag->func.iteratorAtIndex(bag, index, ptr)
  412.  
  413. #define WMBagIndexForIterator(bag, ptr) bag->func.indexForIterator(bag, ptr)
  414.  
  415.     
  416.     
  417. #define WM_ITERATE_BAG(bag, var, i) \
  418.           for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
  419.         var = WMBagNext(bag, &(i)))
  420.  
  421. #define WM_ETARETI_BAG(bag, var, i) \
  422.           for (var = WMBagLast(bag, &(i)); (i) != NULL; \
  423.         var = WMBagPrevious(bag, &(i)))
  424.  
  425.     
  426.     
  427. /*-------------------------------------------------------------------------*/
  428.  
  429. /* WMData handling */
  430.  
  431. /* Creating/destroying data */
  432.  
  433. WMData* WMCreateDataWithCapacity(unsigned capacity);
  434.  
  435. WMData* WMCreateDataWithLength(unsigned length);
  436.  
  437. WMData* WMCreateDataWithBytes(void *bytes, unsigned length);
  438.  
  439. WMData* WMCreateDataWithBytesNoCopy(void *bytes, unsigned length);
  440.  
  441. WMData* WMCreateDataWithData(WMData *aData);
  442.  
  443. WMData* WMRetainData(WMData *aData);
  444.  
  445. void WMReleaseData(WMData *aData);
  446.  
  447. /* Adjusting capacity */
  448.  
  449. void WMSetDataCapacity(WMData *aData, unsigned capacity);
  450.  
  451. void WMSetDataLength(WMData *aData, unsigned length);
  452.  
  453. void WMIncreaseDataLengthBy(WMData *aData, unsigned extraLength);
  454.  
  455. /* Accessing data */
  456.  
  457. const void* WMDataBytes(WMData *aData);
  458.  
  459. void WMGetDataBytes(WMData *aData, void *buffer);
  460.  
  461. void WMGetDataBytesWithLength(WMData *aData, void *buffer, unsigned length);
  462.  
  463. void WMGetDataBytesWithRange(WMData *aData, void *buffer, WMRange aRange);
  464.  
  465. WMData* WMGetSubdataWithRange(WMData *aData, WMRange aRange);
  466.  
  467. /* Testing data */
  468.  
  469. Bool WMIsDataEqualToData(WMData *aData, WMData *anotherData);
  470.  
  471. unsigned WMGetDataLength(WMData *aData);
  472.  
  473. unsigned WMGetDataHash(WMData *aData);
  474.  
  475. /* Adding data */
  476.  
  477. void WMAppendDataBytes(WMData *aData, void *bytes, unsigned length);
  478.  
  479. void WMAppendData(WMData *aData, WMData *anotherData);
  480.  
  481. /* Modifying data */
  482.  
  483. void WMReplaceDataBytesInRange(WMData *aData, WMRange aRange, void *bytes);
  484.  
  485. void WMResetDataBytesInRange(WMData *aData, WMRange aRange);
  486.  
  487. void WMSetData(WMData *aData, WMData *anotherData);
  488.  
  489.     
  490. void WMSetDataFormat(WMData *aData, unsigned format);
  491.     
  492. unsigned WMGetDataFormat(WMData *aData);
  493. /* Storing data */
  494.  
  495.  
  496. /*--------------------------------------------------------------------------*/
  497.  
  498.  
  499. WMNotification *WMCreateNotification(char *name, void *object, void *clientData);
  500.  
  501. void WMReleaseNotification(WMNotification *notification);
  502.  
  503. WMNotification *WMRetainNotification(WMNotification *notification);
  504.  
  505. void *WMGetNotificationClientData(WMNotification *notification);
  506.  
  507. void *WMGetNotificationObject(WMNotification *notification);
  508.  
  509. char *WMGetNotificationName(WMNotification *notification);
  510.  
  511.  
  512. void WMAddNotificationObserver(WMNotificationObserverAction *observerAction, 
  513.                    void *observer, char *name, void *object);
  514.  
  515. void WMPostNotification(WMNotification *notification);
  516.  
  517. void WMRemoveNotificationObserver(void *observer);
  518.  
  519. void WMRemoveNotificationObserverWithName(void *observer, char *name, 
  520.                       void *object);
  521.  
  522. void WMPostNotificationName(char *name, void *object, void *clientData);
  523.  
  524. WMNotificationQueue *WMGetDefaultNotificationQueue(void);
  525.  
  526. WMNotificationQueue *WMCreateNotificationQueue(void);
  527.  
  528. void WMDequeueNotificationMatching(WMNotificationQueue *queue, 
  529.                    WMNotification *notification, 
  530.                    unsigned mask);
  531.  
  532. void WMEnqueueNotification(WMNotificationQueue *queue,
  533.                WMNotification *notification,
  534.                WMPostingStyle postingStyle);
  535.  
  536. void WMEnqueueCoalesceNotification(WMNotificationQueue *queue, 
  537.                    WMNotification *notification,
  538.                    WMPostingStyle postingStyle,
  539.                    unsigned coalesceMask);
  540.  
  541.  
  542. /*......................................................................*/
  543.  
  544. WMUserDefaults *WMGetStandardUserDefaults(void);
  545.  
  546. WMUserDefaults *WMGetDefaultsFromPath(char *path);
  547.  
  548. void WMSynchronizeUserDefaults(WMUserDefaults *database);
  549.  
  550. void WMSaveUserDefaults(WMUserDefaults *database);
  551.  
  552. void WMEnableUDPeriodicSynchronization(WMUserDefaults *database, Bool enable);
  553.  
  554. proplist_t WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName);
  555.  
  556. void WMSetUDObjectForKey(WMUserDefaults *database, proplist_t object,
  557.              char *defaultName);
  558.  
  559. void WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName);
  560.  
  561. /* you can free the returned string */
  562. char *WMGetUDStringForKey(WMUserDefaults *database, char *defaultName);
  563.  
  564. int WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName);
  565.  
  566. float WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName);
  567.  
  568. Bool WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName);
  569.  
  570. void WMSetUDStringForKey(WMUserDefaults *database, char *value, 
  571.              char *defaultName);
  572.  
  573. void WMSetUDIntegerForKey(WMUserDefaults *database, int value, 
  574.               char *defaultName);
  575.  
  576. void WMSetUDFloatForKey(WMUserDefaults *database, float value, 
  577.             char *defaultName);
  578.  
  579. void WMSetUDBoolForKey(WMUserDefaults *database, Bool value,
  580.                char *defaultName);
  581.  
  582. proplist_t WMGetUDSearchList(WMUserDefaults *database);
  583.  
  584. void WMSetUDSearchList(WMUserDefaults *database, proplist_t list);
  585.  
  586. extern char *WMUserDefaultsDidChangeNotification;
  587.  
  588.  
  589. /*-------------------------------------------------------------------------*/
  590.  
  591. /* WMHost: host handling */
  592.  
  593. WMHost* WMGetCurrentHost();
  594.  
  595. WMHost* WMGetHostWithName(char* name);
  596.  
  597. WMHost* WMGetHostWithAddress(char* address);
  598.  
  599. WMHost* WMRetainHost(WMHost *hPtr);
  600.  
  601. void WMReleaseHost(WMHost *hPtr);
  602.  
  603. /*
  604.  * Host cache management
  605.  * If enabled, only one object representing each host will be created, and
  606.  * a shared instance will be returned by all methods that return a host.
  607.  * Enabled by default.
  608.  */
  609. void WMSetHostCacheEnabled(Bool flag);
  610.  
  611. Bool WMIsHostCacheEnabled();
  612.  
  613. void WMFlushHostCache();
  614.  
  615. /*
  616.  * Compare hosts: Hosts are equal if they share at least one address
  617.  */
  618. Bool WMIsHostEqualToHost(WMHost* hPtr, WMHost* anotherHost);
  619.  
  620. /*
  621.  * Host names.
  622.  * WMGetHostName() will return first name (official) if a host has several.
  623.  * WMGetHostNames() will return a R/O WMBag with all the names of the host.
  624.  */
  625. char* WMGetHostName(WMHost* hPtr);
  626.  
  627. /* The returned bag is R/O. Do not modify it, and do not free it! */
  628. WMBag* WMGetHostNames(WMHost* hPtr);
  629.  
  630. /*
  631.  * Host addresses.
  632.  * Addresses are represented as "Dotted Decimal" strings, e.g. "192.42.172.1"
  633.  * WMGetHostAddress() will return an arbitrary address if a host has several.
  634.  * WMGetHostAddresses() will return a R/O WMBag with all addresses of the host.
  635.  */
  636. char* WMGetHostAddress(WMHost* hPtr);
  637.  
  638. /* The returned bag is R/O. Do not modify it, and do not free it! */
  639. WMBag* WMGetHostAddresses(WMHost* hPtr);
  640.  
  641.  
  642. /*-------------------------------------------------------------------------*/
  643.  
  644. /* WMConnection functions */
  645.  
  646. WMConnection* WMCreateConnectionAsServerAtAddress(char *host, char *service,
  647.                                                   char *protocol);
  648.  
  649. WMConnection* WMCreateConnectionToAddress(char *host, char *service,
  650.                                           char *protocol);
  651.  
  652. WMConnection* WMCreateConnectionToAddressAndNotify(char *host, char *service,
  653.                                                    char *protocol);
  654.  
  655. void WMCloseConnection(WMConnection *cPtr);
  656.  
  657. void WMDestroyConnection(WMConnection *cPtr);
  658.  
  659. WMConnection* WMAcceptConnection(WMConnection *listener);
  660.  
  661. /* Release the returned data! */
  662. WMData* WMGetConnectionAvailableData(WMConnection *cPtr);
  663.  
  664. int WMSendConnectionData(WMConnection *cPtr, WMData *data);
  665.  
  666. Bool WMEnqueueConnectionData(WMConnection *cPtr, WMData *data);
  667.  
  668. #define WMFlushConnection(cPtr)  WMSendConnectionData((cPtr), NULL)
  669.  
  670. void WMSetConnectionDelegate(WMConnection *cPtr, ConnectionDelegate *delegate);
  671.  
  672. /* Connection info */
  673.  
  674. char* WMGetConnectionAddress(WMConnection *cPtr);
  675.  
  676. char* WMGetConnectionService(WMConnection *cPtr);
  677.  
  678. char* WMGetConnectionProtocol(WMConnection *cPtr);
  679.  
  680. void WMSetConnectionNonBlocking(WMConnection *cPtr, Bool flag);
  681.  
  682. void* WMGetConnectionClientData(WMConnection *cPtr);
  683.  
  684. void WMSetConnectionClientData(WMConnection *cPtr, void *data);
  685.  
  686. unsigned int WMGetConnectionFlags(WMConnection *cPtr);
  687.  
  688. void WMSetConnectionFlags(WMConnection *cPtr, unsigned int flags);
  689.  
  690. int WMGetConnectionSocket(WMConnection *cPtr);
  691.  
  692. WMConnectionState WMGetConnectionState(WMConnection *cPtr);
  693.  
  694. void WMSetConnectionSendTimeout(WMConnection *cPtr, unsigned int timeout);
  695.  
  696.  
  697. /* Global variables */
  698.  
  699. extern int WCErrorCode;
  700.  
  701.  
  702. /*-------------------------------------------------------------------------*/
  703.  
  704.  
  705.  
  706. #ifdef __cplusplus
  707. }
  708. #endif /* __cplusplus */
  709.  
  710.  
  711. #endif
  712.